<?php
	//header("Content-type: application/vnd.ms-word");
	header("Content-type: application/vnd.ms-excel");
	//header("Content-Disposition: attachment;Filename=Diemthi_.doc");
	header("Content-Disposition: attachment;Filename=ThongKeCauHoi_.xls");
		//header("Content-Disposition: attachment;Filename=Bangdiem_.xls");
	header("Pragma: no-cache");
?>
<div id="blueBar"></div>
<div id="globalContainer">
	<?php echo $this->render("navigation.phtml");?>
	<div id="content" class="hasLeftCol">
		<div id="contentCol" class="hasRightCol">
			<div id="rightCol" >
				<div class="name-page-cms"><p style="text-align: center;font-weight: 600;font-size: 18px;">TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN</p><br/>
					<p style="text-align: center;font-weight: 600;font-size: 18px;">KHOA HỆ THỐNG THÔNG TIN </p>
				</div>
				<div class="name-page-cms"><p style="text-align: center;font-size: 16px;"><b>Thống kê câu hỏi trên hệ thống</b> </p>
				</div>
			</div>		
			<div id="contentArea">
				<div class="statistic-table">
					<table class="table-test">
						<tr>
							<th colspan="2" style="text-align: left;">Ngày thống kê: <?php echo date("d-m-Y G:i")?> 
							</th>
						</tr>
						<tr>
							<th colspan="2" style="text-align: left;">Người thống kê: <?php
									$auth = Zend_Auth::getInstance();
									if ($auth->hasIdentity())
							  			$userhaslogin = $auth->getStorage()->read();  		
									echo $userhaslogin->firstname." ".$userhaslogin->lastname;	
									?>
							</th>
						</tr>
						<tr>
							<th colspan="5" class="head-title-th">Có <?php echo $this->dataStatistic['total'];?> câu hỏi thuộc <?php echo $this->dataStatistic['AmoutSubject']; ?> môn học trên hệ thống
							</th>
						</tr>
						<tr>
							<td colspan="5"><hr/></td>
						</tr>
						<?php if(count($this->dataStatistic['InfoQuestionTeacher'])>0)
								foreach($this->dataStatistic['InfoQuestionTeacher'] as $keyTeacher=>$ItemTeacher){
						?>
						
						<tr>
							<td colspan="5" class="name-teacher-question-test">Giảng viên <?php echo $ItemTeacher['ObjTeacher']['firstname']." ".$ItemTeacher['ObjTeacher']['lastname'] ;?>
								tạo <?php echo $ItemTeacher['TotalQuestionTeacherCreate'] ?> câu hỏi và <?php echo $ItemTeacher['TotalTestTeacherCreate'] ?> đề thi 
							</td>
						</tr>						
						

						<?php }  ?>
						<tr>
							<td colspan="5"><hr/></td>
						</tr>
						<?php if(count($this->dataStatistic['Subject'])>0)
								foreach($this->dataStatistic['Subject'] as $key=>$Item){
						?>
						<tr>
							<th class="statistc-title-subject-th"><p class="statistc-title-subject"> Môn học <?php echo $Item['ObjSubject']['full_name']; ?> có <?php echo $Item['TotalQuestionInOneSubject']; ?> câu hỏi thuộc <?php echo $Item['TotalChapterSubject']; ?> chủ đề</p> </th>
						</tr>
						<?php if(count($Item['InfoAllChapterSubject'])>0){
								foreach($Item['InfoAllChapterSubject'] as $keyInfoAllChapter=>$ItemInfoAllChapter){
						?>
						<tr>
							<th style="color: #6eac2c; font-weight: 600;">Chủ đề <?php echo ($keyInfoAllChapter+1).": ";  echo $ItemInfoAllChapter['NameChapterSubject']; ?> có <?php echo $ItemInfoAllChapter['AmountQuestionInOneChapterSubject']; ?> câu hỏi </th>
						</tr>
						<tr>
							<td colspan="5">
								<table style="width: 400px;">
									<?php if(count($ItemInfoAllChapter['AmountTypeQuesInOneChapterSubject'])>0){
										foreach($ItemInfoAllChapter['AmountTypeQuesInOneChapterSubject'] as $keytemp=>$AmountTypeQuesInOneChapterSubjectItem){
										if($keytemp=="TrueFalse")
											$nameTypeQues="đúng sai";	
										if($keytemp=="Multiplechoice")
											$nameTypeQues="nhiều lựa chọn";	
										if($keytemp=="Matching")
											$nameTypeQues="ghép cặp đôi";	
										if($keytemp=="Completion")
											$nameTypeQues="điền khuyết";	
										if($keytemp=="Essay")
											$nameTypeQues="tự luận";	
										if($keytemp=="ShortAnswer")
											$nameTypeQues="trả lời ngắn";	
									?>
									<tr>
										<td>Câu hỏi <?php echo $nameTypeQues; ?> có:
										</td>
										<td><?php echo $AmountTypeQuesInOneChapterSubjectItem; ?> câu
										</td>
									</tr>
									<?php } }  ?>
								</table>
							</td>
						</tr>
						<?php } }  ?>
						<?php }  ?>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
